{template 'header'}
<script src="../addons/bsht_vcard/res/js/MagicZoom.js"></script>
<div class='container' style='padding: 0 5px 10px; margin: 0; width: 100%'>
	<ul class="nav nav-tabs">
		<li class="active"><a href="{php echo $this->createWebUrl('listyaoqing');}">邀请列表</a></li>

		<!--li><a href="{php echo $this->createWebUrl('listyaoqing_add',array('op'=>'add'));}">添加邀请</a></li-->
	</ul>

<!--div class="panel panel-info">
	<div class="panel-heading"></div>
</div-->

<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
        	<input type="hidden" name="m" value="bsht_tbk" />
        	<input type="hidden" name="do" value="listshow" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-3">
					<input class="form-control" name="keyword" id="" placeholder="输入昵称、openidID" type="text" value="{$_GPC['keyword']}">
				</div>

				
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
					<div class="col-sm-8 col-lg-2">
						<select name="status" class="form-control">
							<option value="1" {if intval($_GPC['status']) == 1}selected="selected"{/if}>启用</option>
							<option value="0" {if intval($_GPC['status']) == 0}selected="selected"{/if}>禁用</option>
						</select>
					</div>
				

                                <div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					&nbsp;&nbsp;
					<a onclick="return confirm('该操作比较耗时，确认吗？'); return false;" href="{php echo $this->createWebUrl('list_yaoqing_delall');}" title="删除" class="btn btn-sm btn-danger"><i class="fa fa-remove"></i> 一键清空邀请记录</a>
				</div>
			</div>
 			<div class="form-group">
			</div>
		</form>
		
	</div>
 
    </div>
    <div style="padding:15px;">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr style="width:100%">
				    <th width="80" style="text-align:center">ID</th>	
				    <th width="100" style="text-align:center">排序</th>	
					<th width="20%" style="text-align:left">基础信息</th>
					
					<th width="10%" style="text-align:center">其他信息</th>

					
					<th width="auto" style="text-align:center">统计</th>
					
					<th width="100" style="text-align:center">邀请头像</th>
					<th width="100" style="text-align:center">客服消息</th>

                    <th width="20%" style="text-align:right">操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}


                <tr>

                    <td style="text-align:center">{$row['id']}</td>
					<td style="text-align:center">{$row['displayorder']}</td>
					<td style="text-align:left">奖励邀请者积分：{$row['score']}<br>昵称：{$row['nickname']}<br><span class="label label-info label-xs">{$row['openid']}</span></td>
					
					<td style="text-align:center">{if $row['status']==1}<span class="label label-success status" id="{$row['id']}">开启</span>{/if}{if $row['status']==0}<span class="label label-danger status" id="{$row['id']}">关闭</span>{/if}<br><br><span class="label label-success"><a href="{php echo $this->createWebUrl('listuser',array('id'=>$row['yuser']['id']))}" style="color:#fff" target="_blank"><i class="fa fa-credit-card"></i> 邀请人：{$row['yuser']['nickname']}</a></span></td>


					<td style="text-align:center">资料创建时间：{php echo date('Y-m-d H:i:s',$row['ctime'])}<br>最后访问时间：{php echo date('Y-m-d H:i:s',$row['vtime'])}</td>

					<td style="text-align:center">
					{if !empty($row['avatar'])}
					<a  href="{php echo tomedia($row['avatar'])}" class="MagicThumb">
					<img src="{php echo tomedia($row['avatar'])}" style="height:40px;width:40px"></a>&nbsp;&nbsp;
					{else}
					暂无图片
					{/if}
					</td>


					<td style="text-align:center">{if $row['follow']==1}<a class="label label-success" title="发送客服消息" href="index.php?c=mc&a=notice&do=tpl&id={$row['fanid']}" target="_blank"><i class="fa fa-comment-o"></i> 点击发送</a>{else}<a class="label label-warning" title="邀请暂未关注，不能发送客服消息！" href="javascript:"><i class="fa fa-exclamation-circle"></i> 无法使用</a>{/if}</td>

<td style="text-align:right">

					

					<!--a class="btn   btn-default" title="编辑" href="{php echo $this->createWebUrl('listyaoqing_add',array('op'=>'edit','id'=>$row['id']))}" ><i class="fa fa-edit"></i> 编辑</a-->
					

					{if $row['follow']==1}
					<a class="btn  btn-danger" rel="tooltip" href="javascript:void();" onclick="drop_confirm('您确定要删除吗?删除不可恢复，同时删除所有相关数据！', '{php echo $this->createWebUrl('listyaoqing_del',array('id'=>$row['id']))}');" title="删除">扣邀请者积分并取消邀请记录<i class="fa fa-times"></i></a>
					{else}
					<a class="btn  btn-info" rel="tooltip" href="javascript:void();">该用户已取消关注，无须操作<i class="fa fa-times"></i></a>
					{/if}
</td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>

</div>
<script>
            function drop_confirm(msg, url){
            if (confirm(msg)){
            window.location = url;
            }
            }
$(document).ready(function(){ 
　　$(".status").click(function(){ 

var cid=$(this).attr('id');
var url = "{php echo $this->createWebUrl('listyaoqing_ajax');}&id="+cid;		
$.post(url, function(dat){
dat = eval('('+dat+')');

if (dat.status==1)
{
var cid=dat.id;
$("#"+cid).removeClass("label-danger");
$("#"+cid).addClass("label-success");
$("#"+cid).hide();
$("#"+cid).html('开启').fadeIn(500);
}

if (dat.status==0)
{
var cid=dat.id;
$("#"+cid).removeClass("label-success");
$("#"+cid).addClass("label-danger");
$("#"+cid).hide();
$("#"+cid).html('关闭').fadeIn(500);
}

});
　　　//alert(cid);
　　}); 
}); 
</script>
　
{template 'footer'}